package wordit.impl.letterCells;

import wordit.Dictionary;
import wordit.LetterSequence;
import wordit.ea.FitnessFunction;
import wordit.ea.Genome;

public class LetterCellFitness implements FitnessFunction {

	private final Dictionary dictionary;

	public LetterCellFitness(Dictionary dictionary) {
		this.dictionary = dictionary;
	}

	@Override
	public double eval(Genome gen) {
		LetterCellGenome LCGenome = (LetterCellGenome) gen;
		double fitness = 0;	
		
		for (LetterSequence seq : LCGenome.getSequences()) {
			fitness += seq.getScore(dictionary);
		}
		
		return fitness;
	}
}
